<?php
class RegisterController {
	public function doRegisterController() {
		$generalView = new PageView();
		$registerView = new RegisterView();
		$registerHandler = new RegisterHandler();
		$registerbox = $registerView -> createRegisterBox();
		$content = '';
		if ($registerView -> triedToRegister()) {
				// Get input name and password
				$name = $registerView -> getUserName();
				$password = $registerView -> getPassword();
				// Register
				$registration = $registerHandler -> doRegister($name, $password);
				if ($registration === true) {
					// If register succeeded
					$content = $registerView -> registerSuccess();
					return $content;
				}
				else {
					$content = $registerbox;
					return $content;
				}
			}
		$content .= $registerbox;
		return $content;
	}

}
